/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function validateAll(form){
    //regex
    var ck_password =  /^[A-Za-z0-9!@#$%^&*()_]{8,20}$/;
    var noerror = true; //condition
    
    if (!ck_password.test(form.currpass.value)) {
        document.getElementById("errorcurrent").innerHTML = 'Enter a valid password.';
        noerror = false;
    }
    else {
        document.getElementById("errorcurrent").innerHTML = '';
    }
    if (!ck_password.test(form.newpass1.value) || !ck_password.test(form.newpass2.value)) {
        document.getElementById("errorpassword").innerHTML = 'Enter a valid password.';
        noerror = false;
    }
    else if(form.newpass1.value != form.newpass2.value){
        document.getElementById("errorpassword").innerHTML = 'Re-type password does not match.';
        noerror = false;
    }
    else{
        document.getElementById("errorpassword").innerHTML = '';
    }    
    
    return noerror;
    
}